#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        string s; cin >> s;
        int f1 = 0, f2 = 0;
        for (int i = 0; i < s.size(); i++) {
            for (int j = i + 1; j < s.size(); j++) {
                for (int k = j + 1; k < s.size(); k++) {
                    if (s[i] == 'D' && s[j] == 'F' && s[k] == 'S') f1 = 1;
                    if (s[i] == 'd' && s[j] == 'f' && s[k] == 's') f2 = 1;
                }
            }
        }
        cout << f1 << " " << f2 << endl;
    }
    return 0;
}